﻿///////////////////////////////////////////////////////////////////////////////
//
// This file is part of the BassDrop project
//   https://code.google.com/p/bass-drop/
//
//
// Creator:	Gergely Krajcsovszki (krajcsovszkig@hotmail.com)
// Date:	2014-02-16 11:35
//
//
// Copyright © 2013-2014. Gergely Krajcsovszki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BassDrop.Core.Common.Cloud.Requests.Assets
{
	/// <summary>
	/// Event args type for events signalling error in the execution of cloud requests
	/// </summary>
	public class CloudRequestErroredEventArgs : EventArgs
	{
		/// <summary>
		/// The request that was successfully executed
		/// </summary>
		public CloudRequestBase Request
		{
			get;
			private set;
		}

		/// <summary>
		/// True if the request may be able to successfully execute later.
		/// Generally it means it will be retried.
		/// </summary>
		public bool Repairable
		{
			get;
			private set;
		}

		/// <summary>
		/// If an exception caused the error, this is it.
		/// </summary>
		public Exception Cause
		{
			get;
			private set;
		}

		/// <summary>
		/// The time of completion
		/// </summary>
		public DateTime Timestamp
		{
			get;
			private set;
		}

		/// <summary>
		/// Constructs a new event args object
		/// </summary>
		/// <param name="request">the request object</param>
		/// <param name="repairable">true if the request may be able to successfully execute later.</param>
		/// <param name="cause">if an exception caused the error, this is it.</param>
		/// <param name="timestamp">the time of error. If null is passed or left out, the current time is used</param>
		public CloudRequestErroredEventArgs( CloudRequestBase request, bool repairable, Exception cause, DateTime? timestamp = null )
		{
			Request = request;
			Repairable = repairable;
			Cause = cause;
			Timestamp = timestamp ?? DateTime.Now;
		}
	}
}
